﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TemplateFoundation.Core;

namespace TemplateFoundation.Tests.UnitTests.TemplateFoundation.Core
{
    /// <summary>
    /// Tests core type extension methods of the Extensions class in TemplateFoundation.Core
    /// </summary>
    [TestClass]
    public class CoreTypeExtensionsTest
    {
        [TestMethod]
        public void TestDateTimeGetQuarter()
        {
            for(int i=1;i<=12;i++)
            {
                var dt = new DateTime(DateTime.Now.Year, i, 1);    

                if(i<=3)
                {
                    Assert.IsTrue(dt.GetQuarter()==1,string.Format("Expected {0} to be in Q1", dt.ToString("MMMM")));
                }
                else if (i<=6)
                {
                    Assert.IsTrue(dt.GetQuarter()==2, string.Format("Expected {0} to be in Q2", dt.ToString("MMMM")));
                }
                else if (i<=9)
                {
                    Assert.IsTrue(dt.GetQuarter()==3, string.Format("Expected {0} to be in Q3", dt.ToString("MMMM")));
                }
                else
                {
                    Assert.IsTrue(dt.GetQuarter()==4, string.Format("Expected {0} to be in Q4", dt.ToString("MMMM")));
                }
            }
        }
    }
}
